package com.alibaba.algo.controller.user;

import com.alibaba.algo.apiimpl.user.SysAppServiceImpl;
import com.alibaba.algo.cooperation.common.BaseResult;
import com.alibaba.algo.cooperation.usercenter.GlobalResultStatus;
import com.alibaba.algo.cooperation.usercomponent.vo.req.user.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping(value = "/usercenter-admin-app/admin/sysApp")
public class SysAppController {

    @Autowired
    private SysAppServiceImpl sysAppService;

    @PostMapping("/selectList")
    public BaseResult selectList() {
        return sysAppService.selectList();
    }

    @PostMapping("/selectAppByUser")
    public BaseResult selectAppByUser(@RequestBody SelectAppByUserReqVO vo) {
        if (StringUtils.isEmpty(vo.getUserId())){
            return BaseResult.buildError(GlobalResultStatus.PARAM_APP_CODE_ERROR.getCode(),GlobalResultStatus.PARAM_APP_CODE_ERROR.getMsg());
        }
        return sysAppService.selectAppByUserId(vo);
    }

}